home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
System Booster
/
System Booster.iso
/
Archives
/
ForCLI
/
0Utils13.lha
/
0Utils
/
WB_Delete.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-20
|
4KB
|
199 lines
/******************************************************************************
MODULE
WB_Delete.c
DESCRIPTION
Delete a file and it's .info File and delete
its DiskObject on WB.
NOTES
Kickstart 2.0+ required
compiles w/ SAS/C v6.51
BUGS
none known
TODO
implement recursion and wildcards
TEST!!!!!!!!!!
DeleteDO.c verwendete:
if (!file.info)
touch file.info
deletediskobject(file)
if (touched file.info)
delete(file.info)
das deutet an, dass deletediskobject
ein file.info dringend braucht.
aber das löschte nur das diskobject,
weder file, noch file.info
EXAMPLES
SEE ALSO
INDEX
HISTORY
12-02-95 b_noll created
20-02-95 b_noll restructured source
21-02-95 b_noll added version/format-prefix/offset
20-03-95 b_noll added args diagnostics
AUTHOR
Bernd Noll, Brunnenstrasse 55, D-67661 Kaiserslautern
b_noll@informatik.uni-kl.de
******************************************************************************/
/**************************************
Includes
**************************************/
#ifndef EXEC_LIBRARIES_H
# include <exec/libraries.h>
#endif /* EXEC_LIBRARIES_H */
#ifndef CLIB_EXEC_PROTOS_H
# include <clib/exec_protos.h>
#endif /* CLIB_EXEC_PROTOS_H */
#ifndef DOS_DOS_H
# include <dos/dos.h>
#endif /* DOS_DOS_H */
#ifndef CLIB_DOS_PROTOS_H
# include <clib/dos_protos.h>
#endif /* CLIB_DOS_PROTOS_H */
#include <proto/dos.h>
#include <proto/exec.h>
/* ******************** USER INCLUDES ******************** */
#ifndef CLIB_ICON_PROTOS_H
# include <clib/icon_protos.h>
#endif /* CLIB_ICON_PROTOS_H */
#include <proto/icon.h>
#include <string.h>
/* ******************** USER INCLUDES ******************** */
/**************************************
Defines & Structures
**************************************/
#ifndef ABSEXECBASE
#define ABSEXECBASE ((struct ExecBase **)4L)
#endif
struct _arg {
/* ******************** USER FORMAT ******************** */
#define FORMAT "FILE/M/A,ONLYICONS/S"
STRPTR* file;
ULONG onlyIcons;
#define ICONNAME "icon.library"
/* ******************** USER FORMAT ******************** */
}; /* struct _argv */
#define MAXPATHLEN 256
#define MAXLINELEN 256
#define VERSIONPREFIX "\0$VER: "
#define VERSIONOFFSET 0
#define FORMATPREFIX "\0$ARG: "
#define FORMATOFFSET 7
/**************************************
Implementation
**************************************/
long _main (void)
{
const char * version = VERSIONPREFIX "WB_Delete 1.2 " __AMIGADATE__ + VERSIONOFFSET;
long retval = RETURN_FAIL;
struct ExecBase*SysBase = *ABSEXECBASE;
struct Library* DOSBase;
struct Library* IconBase;
if (DOSBase = OpenLibrary (DOSNAME, 37)) {
struct _arg argv = { 0 };
APTR args;
retval = RETURN_ERROR;
if (args = (void*)ReadArgs(FORMATPREFIX FORMAT + FORMATOFFSET, (LONG*)&argv, NULL)) {
/* ******************** USER BODY ******************** */
long cnt;
UBYTE buffer [MAXPATHLEN];
BPTR lock;
if (IconBase = OpenLibrary(ICONNAME, 37)) {
retval = RETURN_OK;
for (cnt = 0; argv.file[cnt] && !retval; ++cnt) {
buffer[0] = 0;
strcat (buffer, argv.file[cnt]);
/* ---- Delete the main file */
if (!argv.onlyIcons)
if (lock = Lock(buffer, SHARED_LOCK)) {
UnLock(lock);
if (!DeleteFile(buffer)) {
retval = RETURN_ERROR;
break;
} /* if */
} /* if */
/* ---- Delete the Icon and the .info file */
/* we delete file.info and diskobject separately, */
/* 'cause else we get probs w/ defdiskobjects */
strcat (buffer, ".info");
if (lock = Lock(buffer, SHARED_LOCK)) {
UnLock(lock);
if (!DeleteFile(buffer)) {
retval = RETURN_ERROR;
break;
} /* if */
} /* if */
/* ---- The rc is always FALSE 'cause of FileNotFound */
DeleteDiskObject(argv.file[cnt]);
} /* for */
CloseLibrary (IconBase);
} /* if */
/* ******************** USER BODY ******************** */
FreeArgs (args);
} /* if */
if (retval > RETURN_WARN)
PrintFault(IoErr(), "WB_Delete");
CloseLibrary (DOSBase);
} /* if */
return (retval);
} /* _main */
/******************************************************************************
***** END WB_Delete.c
******************************************************************************/